home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / networking / amitcp / cp3update1.lha / Update / cp_update / controlpanel.rexx
Encoding:
OS/2 REXX Batch file  |  1995-02-11  |  10.4 KB  |  371 lines

  1. /* $VER ControlPanel 3.50 (4/2/95)
  2. ** $Filename: ControlPanel $
  3. ** $Date: 8.1.95
  4. ** $Creation: 16.12.94
  5. **
  6. ** Arexx Version Of AmiTCP_ControlPanel
  7. **
  8. ** Users rexxreqtools.library
  9. **
  10. ** (C) Copyright 1994-1995 Martin Carl Hunt
  11. **
  12. */
  13.  
  14. Address Command
  15.  
  16. /* Adds Libraries Control Panel Needs */
  17. Call addlibraries()
  18.  
  19. /* Initialieses Varibales Etc. */
  20. Call Initialisation()
  21.  
  22. /* Gets Configuration Details (Prog. Names, Position, Amitcp: */
  23. Call GetConfig()
  24.  
  25. /* If env:user doesn't exist call StartAmiTCP requester */
  26. if ~exists("env:user") then call StartAmiTCP ()
  27.  
  28. /* Get User Details */
  29. call getuserdetails()
  30. /* Main Control Panel Loop */
  31. quit_controlpanel = 0
  32. do until quit_controlpanel
  33.  
  34. reqtitle = "AmiTCP Control Panel - Main Menu    Current
  35.  User:" || usr || "    Real Name:" || relnme
  36.  
  37.  
  38.    MainMenu = rtezrequest("What do you want to do?", ,
  39.       "_Start|S_top|_Connect|_Disconnect|Change _User|_Applications|A_uto|_Quit", ,
  40.       reqtitle, "rtez_flags = ezreqf_centertext",
  41.       topoffset leftoffset "rt_reqpos = reqpos_topleftscr" "rtez_defaultresponse = 6")
  42.  
  43.    if MainMenu == 0 then quit_controlpanel = 1
  44.    if MainMenu == 1 then call Startnet()
  45.    if MainMenu == 2 then call Stopnet()
  46.    if MainMenu == 3 then call LinkUp()
  47.    if MainMenu == 4 then call LinkDown()
  48.    if MainMenu == 5 then call ChangeUser()
  49.    if MainMenu == 6 then call Applications()
  50.    if mainmenu == 7 then run auto.exe
  51.  
  52. end
  53. call delay(250)
  54. "delete t:cp-run#? quiet"
  55. exit
  56.  
  57. /* ----------------------------------------------------- */
  58.  
  59. AddLibraries:
  60. if ~show("L","libs:rexxarplib.library") then
  61. do
  62.   call addlib("libs:rexxarplib.library", 0, -30, 0)
  63.   arplib = 1
  64. end
  65. if ~show("L","libs:rexxsupport.library") then
  66. do
  67.   call addlib("libs:rexxsupport.library", 0, -30, 0)
  68.   supportlib = 1
  69. end
  70. if ~show("L","libs:rexxreqtools.library") then
  71. do
  72.   call addlib("libs:rexxreqtools.library", 0, -30, 0)
  73.   reqtoolslib = 1
  74. end
  75. RETURN
  76.  
  77. /* ----------------------------------------------------- */
  78.  
  79. Initialisation:
  80. runno = 0
  81. NL = '0a'x
  82. quit_controlpanel = 0
  83.  
  84. RETURN
  85.  
  86. /* ----------------------------------------------------- */
  87.  
  88. GetUserDetails:
  89. Relnme = "NOTSET"
  90. USR = "NOTSET"
  91.  
  92. if open(ahandle, "env:realname", "r") then
  93. do
  94.   Relnme = ReadLn(ahandle)
  95.   call close(ahandle)
  96. end
  97.  
  98. if open(bhandle, "env:user", "r") then
  99. do
  100.   USR = ReadLn(bhandle)
  101.   call close(bhandle)
  102. end
  103.  
  104. if USR = "NOTSET" then
  105. do
  106.   call open(dhandle, "env:user", "W")
  107.   call seek(dhandle,0,"B")
  108.   call writeln(dhandle, usr)
  109.   call close(dhandle)
  110. end
  111.  
  112. if Relnme = "NOTSET" then
  113. do
  114.   call open(chandle, "env:realname", "W")
  115.   call seek(chandle,0,"B")
  116.   call writeln(chandle, usr)
  117.   call close(chandle)
  118.   relnme = usr
  119. end
  120. return
  121.  
  122. /* ----------------------------------------------------- */
  123.  
  124. StartAmiTCP:
  125. if exists("Amitcp:bin/startnet") then
  126. do
  127.  choice = rtezrequest( "What do you want to do?", " _Start Amitcp   | _Quit    ", "AmiTCP Control Panel - Startup", "rtez_flags = ezreqf_centertext" "rt_reqpos = reqpos_centerscr")
  128.  if choice == 1 then
  129.  do
  130.    call Startnet()
  131.    "copy amitcp:env/#? env:"
  132.  end
  133.  else exit
  134. end
  135. RETURN
  136.  
  137. /* ----------------------------------------------------- */
  138.  
  139. Startnet:
  140. "Execute amitcp:bin/startnet"
  141. RETURN
  142.  
  143. /* ----------------------------------------------------- */
  144.  
  145. Stopnet:
  146. if show('P','AMITCP') then address AMITCP KILL
  147. RETURN
  148.  
  149. /* ----------------------------------------------------- */
  150.  
  151. LinkUp:
  152. LinkMenu=""
  153. if ~exists("Amitcp:bin/plink") then
  154. do
  155. LinkMenu = rtezrequest("Do You Want To Collect News" , "_Yes |_No |_Cancel", "AmiTCP Control Panel - Choose News Reader", "rtez_flags = ezreqf_centertext" "rt_reqpos = reqpos_centerscr")
  156.   if linkmenu == 1 then address command "run link up news"
  157.   if linkmenu == 2 then address command "run Link Up"
  158. end
  159. else
  160. do
  161.   LinkMenu = rtgetstring(" ", "Enter FTP Batch File Name If Appropriate" ,"AmiTCP Control Panel - Connect", ,
  162.         " _News | _Forget News | News and then _Disconnect | _Cancel ", "rtez_flags = ezreqf_centertext" "rt_reqpos = reqpos_centerscr" ,
  163.         , LM_result)
  164.  
  165.   plinkparams = ""
  166.   if LM_result ~= 0 then
  167.   do
  168.      if LM_Result == 1 then PlinkParams = "Up NEWS Savenew"
  169.      if LM_Result == 2 then PlinkParams = "Up"
  170.      if LM_Result == 3 then PlinkParams = "Up Autonews Savenew"
  171.      if LinkMenu ~= "" then
  172.      do
  173.         if exists(word(linkmenu,1)) then
  174.         do
  175.           PlinkParam = Plinkparams || " Batch " || LinkMenu
  176.         end
  177.         else
  178.         do
  179.            "ED " linkmenu
  180.            PlinkParam = Plinkparams || " Batch " || LinkMenu
  181.         end
  182.      end
  183.      if linkmenu = "" then plinkparam = plinkparams
  184.      "run PLINK" plinkparam
  185.   end
  186.   LM_result = "LM_result"
  187. end
  188. RETURN
  189.  
  190. /* ----------------------------------------------------- */
  191.  
  192. LinkDown:
  193. if exists("amitcp:bin/plink") then "run >nil: plink down"
  194. else "run >nil: link down"
  195. RETURN
  196.  
  197. /* ----------------------------------------------------- */
  198.  
  199. ChangeUser:
  200. name_correct = 0
  201. do until Name_Correct
  202. call open(handle1, "env:realname", "a")
  203. call seek(handle1, 0, "B")
  204. Env_Realname = ReadLn(handle1)
  205. RealName = rtgetstring(Env_Realname, "Enter Your Real Name           " || NL || ,
  206.            "i.e. Fred Bloggs               ", "AmiTCP Control Panel - Change User", ,
  207.            "_Use |_Save |_Cancel", "rtez_flags = ezreqf_centertext" "rt_reqpos = reqpos_centerscr", CU_RESULT)
  208. if CU_Result == 0 then RealName = ENV_Realname
  209. if CU_result ~== 0 then
  210. do
  211.    call seek(handle1, 0, "B")
  212.    call Writeln(handle1, RealName)
  213. end
  214. if CU_result == 2 then
  215. do
  216.    call open(handle2, "Amitcp:env/RealName", "w")
  217.    call Writeln(handle2, Realname)
  218.    call close (handle2)
  219. end
  220. call close (handle)
  221.  
  222. call open(handle, "env:User", "a")
  223. call seek(handle, 0, "B")
  224. Env_User = ReadLn(handle)
  225. CU_Result = "CU_RESULT"
  226. User = rtgetstring(Env_User, "Enter Your User Name           " || NL || ,
  227.       "i.e. Fred                      ", "AmiTCP Control Panel - Change User", ,
  228.       "_Use |_Save |_Cancel", "rtez_flags = ezreqf_centertext" "rt_reqpos = reqpos_centerscr", Cu_result)
  229. if CU_result == 0 then User = Env_user
  230. if CU_result ~== 0 then
  231. do
  232.   call seek(handle, 0, "B")
  233.   call Writeln(handle, User)
  234. end
  235.  
  236. if CU_result == 2 then
  237. do
  238.    call open(handle2, "amitcp:env/User", "w")
  239.    call Writeln(handle2, User)
  240.    call close (handle2)
  241. end
  242.  
  243. Call Close(handle)
  244.  
  245. Name_Correct = rtezrequest("Your REAL NAME is " || RealName || NL ||,
  246.                           "Your USER NAME is " || User || NL || NL ||,
  247.                           "IS This Correct? ", "_Yes |_No", "AmiTCP Control Panel - Change User", ,
  248.                           "rtez_flags = ezreqf_centertext" "rt_reqpos = reqpos_centerscr")
  249. CU_RESULT = "CU_RESULT"
  250. end
  251.  
  252. relnme = RealName
  253. USR = User
  254.  
  255. RETURN
  256.  
  257. /* ----------------------------------------------------- */
  258.  
  259. Applications:
  260. do until Cancel = 0
  261. reqtitle = "AmiTCP Control Panel - Applications Menu    Current User:" || usr ||"    Real Name:" || relnme
  262.  
  263.   Cancel = rtezrequest("Choose Application To Run", ,
  264.         "_E-Mail|_News|_FTP|_WWW|_Gopher|_IRC|_Archie|_Telnet|_More|_Cancel", ,
  265.         reqtitle, "rtez_flags = ezreqf_centertext",
  266.         topoffset leftoffset "rt_reqpos = reqpos_topleftscr" "rtez_defaultresponse = 9")
  267.  
  268.   Choice = Cancel
  269.   if choice == 1 then mailprog
  270.   if choice == 2 then address command newsprog
  271.   if choice == 3 then ftpprog
  272.   if choice == 4 then wwwprog
  273.   if choice == 5 then gopherprog
  274.   if choice == 6 then ircprog
  275.   if choice == 7 then call runprog(archie_gui || " FILE")
  276.   if choice == 8 then "run >nil: telnet_gui.exe"
  277.   if choice == 9 then
  278.   do
  279.     cancel = 3
  280.     do until cancel <2
  281.       Cancel = rtezrequest("Choose Application To Run", ,
  282.           "_Back|_Finger|_Ping|_TraceRoute|_UUXT|_DeArc|_Ed News|_Cancel", ,
  283.           reqtitle, "rtez_flags = ezreqf_centertext",
  284.           topoffset leftoffset "rt_reqpos = reqpos_topleftscr" "rtez_defaultresponse = 1")
  285.  
  286.       choice = cancel
  287.       if choice == 1 then cancel = 1
  288.       if choice == 2 then call runprog(finger_gui || " FILE")
  289.       if choice == 3 then call runprog(Ping_gui || " SCREEN")
  290.       if choice == 4 then call runprog(traceroute_gui || " FILE")
  291.       if choice == 5 then uudecoderprog
  292.       if choice == 6 then dearchiverprog
  293.       if choice == 7 then newsedprog
  294.       if choice == 8 then cancel = 0
  295.     end
  296.   end
  297. end
  298. RETURN
  299.  
  300. /* ----------------------------------------------------- */
  301.  
  302. RunProg:
  303. arg params
  304. prog = word(params,1)
  305. output = word(params,2)
  306. runno = runno + 1
  307. filename2 = ""
  308. filename = "t:cp-run-" || runno
  309. filename2 = filename || ".output"
  310. call open(file, filename, 'w')
  311.  if output == "FILE" then
  312.  do
  313.    line1 = "amitcp:bin/" || prog || ".exe > " filename2
  314.    call writeln(file, line1)
  315.    call writeln(file, "ed " || filename2)
  316.  end
  317.  if output ~== "FILE" then do
  318.    line1 = "amitcp:bin/" || prog || ".exe"
  319.    call writeln(file, line1)
  320.    call writeln(file, "Wait 5 secs")
  321.    call writeln(file, "endcli")
  322.  end
  323. call close(file)
  324. if output ~== "FILE" then address command "newshell con:0/150/640/100/" || prog || "-OUTPUT from " || filename
  325. if output == "FILE" then address command "run execute " || filename
  326. return
  327.  
  328. /* ----------------------------------------------------- */
  329.  
  330. GetConfig:
  331. /* Default Values If s:cp.config doesn't exist */
  332. Amitcp = "Dh1:amitcp"
  333. Mailprog = "mail"
  334. Newsprog = "grn left=30 height=230"
  335. FtpProg = "gui-ftp"
  336. WWWprog = "amosaic"
  337. GopherProg = "gopher"
  338. IrcProg = "gv"
  339. UUDecoderProg = "uuxt-gui"
  340. DeArchiverProg = "GuiArc"
  341. NewsEdProg = "NewsEd_Gui.exe"
  342. topoffset = 100
  343. leftoffset = 10
  344.  
  345. /*Try to open s:cp.config*/
  346. if open(configfile, "s:cp.config", r) then
  347. do
  348.    do until eof(configfile)
  349.       a = readln(configfile)
  350.  
  351.       if upper(word(a,1)) == "AMITCPDIR" then AmiTCP = delword(a, 1, 2)
  352.       if upper(word(a,1)) == "LEFT" then leftoffset = delword(a, 1, 2) 
  353.       if upper(word(a,1)) == "TOP" then topoffset = delword(a, 1, 2)
  354.       if Upper(word(a,1)) == "MAIL" then mailprog = "run" delword(a, 1, 2)
  355.       if upper(word(a,1)) == "NEWS" then Newsprog = "run" delword(a, 1, 2)
  356.       if upper(word(a,1)) == "FTP" then ftpprog = "run" delword(a, 1, 2)
  357.       if upper(word(a,1)) == "WWW" then WWWprog = "run" delword(a, 1, 2)
  358.       if upper(word(a,1)) == "GOPHER" then gopherprog = "run" delword(a, 1, 2)
  359.       if upper(word(a,1)) == "IRC" then IRcprog = "run" delword(a, 1, 2)
  360.       if upper(word(a,1)) == "UUDECODER" then Uudecoderprog = "run" delword(a, 1, 2)
  361.       if upper(word(a,1)) == "DEARCHIVER" then DeArchiverprog = "run" delword(a, 1, 2)
  362.       if upper(word(a,1)) == "NEWSED" then NewsEdprog = "run" delword(a, 1, 2)
  363.  
  364.    end
  365.    call close(configfile)
  366. end
  367. "assign amitcp: "amitcp
  368. leftoffset = "rt_leftoffset = "||leftoffset
  369. topoffset = "rt_topoffset = "||topoffset
  370. RETURN
  371.